import SourceView from "./source_view";
import md2html from '../markdown_parse/markdown_parse_line'
export class SourceAndPreviewView extends SourceView {
    previewElement_; // 双屏右侧的显示元素
    constructor (textModel, selectionModel, viewContainer) {
        super(textModel, selectionModel, viewContainer)  
        const previewElement = document.createElement('pre')
        previewElement.setAttribute('class', 'container-pre preview')
        this.viewContainer_.parentElement.appendChild(previewElement)
        this.previewElement_ = previewElement
    }
    render () {
        this.viewContainer_.innerHTML = this.textModel_.getSpacers() + '\n'
        setTimeout(() => {
            this.updateDomSelection()
        }, 0)
        this.previewElement_.innerHTML = md2html(this.textModel_.getSpacers())
    }
}
export default SourceAndPreviewView